package com.zycfc.zsf.boot.util.http;

import org.slf4j.*;
import com.zycfc.zsf.boot.util.bean.*;
import java.util.*;

public class HttpClientProperties
{
    private static final String PREFIX = "http.client";
    private static final Logger LOGGER;
    public static Long TIME_TO_LIVE;
    public static Integer MAX_TOTAL;
    public static Integer MAX_PER_ROUTE;
    public static Integer RETRY_COUNT;
    public static Boolean REQUEST_SENT_RETRY_ENABLED;
    public static Integer CONNECT_TIMEOUT;
    public static Integer READ_TIMEOUT;
    public static Integer CONNECTION_REQUEST_TIMEOUT;
    public static String ACCEPT_ENCODING;
    public static String ACCEPT_LANGUAGE;
    public static String CONNECTION;
    
    static {
        LOGGER = LoggerFactory.getLogger((Class)HttpClientProperties.class);
        HttpClientProperties.TIME_TO_LIVE = 30L;
        HttpClientProperties.MAX_TOTAL = 500;
        HttpClientProperties.MAX_PER_ROUTE = 500;
        HttpClientProperties.RETRY_COUNT = 0;
        HttpClientProperties.REQUEST_SENT_RETRY_ENABLED = false;
        HttpClientProperties.CONNECT_TIMEOUT = 5000;
        HttpClientProperties.READ_TIMEOUT = 20000;
        HttpClientProperties.CONNECTION_REQUEST_TIMEOUT = 200;
        HttpClientProperties.ACCEPT_ENCODING = "gzip,deflate";
        HttpClientProperties.ACCEPT_LANGUAGE = "zh-CN,zh;q=0.8,en;q=0.6";
        HttpClientProperties.CONNECTION = "keep-alive";
        try {
            final Properties properties = PropertiesUtils.loadFromFile("classpath://http.properties");
            HttpClientProperties.TIME_TO_LIVE = PropertiesUtils.getLong(properties, "http.client.timeToLive", 30L);
            HttpClientProperties.MAX_TOTAL = PropertiesUtils.getInt(properties, "http.client.maxTotal", 500);
            HttpClientProperties.MAX_PER_ROUTE = PropertiesUtils.getInt(properties, "http.client.maxPreRoute", 500);
            HttpClientProperties.RETRY_COUNT = PropertiesUtils.getInt(properties, "http.client.retryCount", 500);
            HttpClientProperties.REQUEST_SENT_RETRY_ENABLED = PropertiesUtils.getBoolean(properties, "http.client.requestSentRetryEnabled", false);
            HttpClientProperties.CONNECT_TIMEOUT = PropertiesUtils.getInt(properties, "http.client.connectTimeout", 5000);
            HttpClientProperties.READ_TIMEOUT = PropertiesUtils.getInt(properties, "http.client.readTimeout", 20000);
            HttpClientProperties.CONNECTION_REQUEST_TIMEOUT = PropertiesUtils.getInt(properties, "http.client.connectionRequestTimeout", 200);
            HttpClientProperties.ACCEPT_ENCODING = PropertiesUtils.getString(properties, "http.client.acceptEncoding", "gzip,deflate");
            HttpClientProperties.ACCEPT_LANGUAGE = PropertiesUtils.getString(properties, "http.client.acceptLanguage", "zh-CN,zh;q=0.8,en;q=0.6");
            HttpClientProperties.CONNECTION = PropertiesUtils.getString(properties, "http.client.connection", "keep-alive");
        }
        catch (Exception e) {
            HttpClientProperties.LOGGER.error("\u8bfb\u53d6Http\u914d\u7f6e\u5931\u8d25\uff01\uff0c\u4f7f\u7528\u9ed8\u8ba4\u914d\u7f6e");
        }
    }
}
